{include file="include/top"}
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" action="javascript:;">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>用户名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="username" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="password" name="pass" required="" lay-verify="pass"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                    <span class="x-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="re_password" name="repass" required="" lay-verify="repass"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>选择权限组</label>
                <div class="layui-input-inline layui-show-xs-block">
                    <select name="g_id">
                        <option value="">选择用户组</option>
                        {volist name="groupList" id="groupList"}
                        <option value="{$groupList.id}">{$groupList.title}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>状态</label>
                <div class="layui-input-inline layui-show-xs-block">
                    <select name="status">
                        <option value="">选择状态</option>
                        <option value="0">禁用</option>
                        <option value="1">启用</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="" onclick="return add()">
                    增加
                </button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
    });
function add()
{
    var username=$("#username").val();
    var password = $("#password").val();
    var repwd = $("#re_password").val();
    var g_id = $("[name=g_id]").val();
    var status = $("[name=status]").val();
    if(password!=repwd){
        layer.msg('两次密码不一致')
        return false;
    }
    $.ajax({
        type: 'POST',
        url: '{:url("admin/add")}',
        data: {ad_name: username,ad_pwd:repwd,g_id:g_id,ad_state:status},
        success: function (data) {
            if(data.code>0){
                layer.msg(data.msg, {icon: 6, time: 1000});
                setTimeout(function () {
                    xadmin.close();
                    xadmin.father_reload();
                },1000)
            }else{
                layer.msg(data.msg, {icon: 5, time: 1000});
            }
        },
        error: function (data) {
            console.log(data.msg);
        },
    });
}

</script>

</body>

</html>
